import tkinter as tk
import ctypes
import time
from ctypes import *





#def close_window():
    #root_window.destroy()

root_window=tk.Tk()
root_window.title("易键鼠测试工具")
#root_window.overrideredirect(True)

root_window.geometry('150x80')
#close_button=tk.Button(root_window,text="关闭",command=close_window)
#close_button.pack()
label_connect=tk.Label(root_window,text="盒子未连接，连接中")
label_tr=tk.Label(root_window,text="未启用,按F6启动")
label_err=tk.Label(root_window,text="错误:0")
label_connect.pack()
label_tr.pack()
label_err.pack()




is_box_connected=False

objdll=ctypes.windll.LoadLibrary('./msdk.dll')
hdl=objdll.M_Open(1)

def check_box():
    global is_box_connected
    global hdl
    global objdll
    if (hdl !=-1):
        label_connect.config(text="盒子已连接")
        is_box_connected=True
    else:
        label_connect.config(text="盒子未连接，连接中")
        is_box_connected=False
        hdl=objdll.M_Open(1)


    label_connect.after(1000,check_box)


def run_func():
    #todo 

def show_error():
    #todo



root_window.mainloop()